package sk.tuke.persistance;

import java.io.Serializable;
import javax.persistence.*;

@Entity
@org.hibernate.annotations.Proxy(lazy = false)
@Table(name = "DISEASE_SYMPTOM")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class DiseaseSymptomPo implements Serializable {

	private static final long serialVersionUID = 1L;

	public DiseaseSymptomPo() {
	}

	public boolean equals(Object aObj) {
		if (aObj == this)
			return true;
		if (!(aObj instanceof DiseaseSymptomPo))
			return false;
		DiseaseSymptomPo diseasesymptom = (DiseaseSymptomPo) aObj;
		if (getId() != diseasesymptom.getId())
			return false;
		if (getDisease() == null) {
			if (diseasesymptom.getDisease() != null)
				return false;
		} else if (!getDisease().equals(diseasesymptom.getDisease()))
			return false;
		if (getSymptom() == null) {
			if (diseasesymptom.getSymptom() != null)
				return false;
		} else if (!getSymptom().equals(diseasesymptom.getSymptom()))
			return false;
		return true;
	}

	public int hashCode() {
		int hashcode = 0;
		hashcode = hashcode + (int) getId();
		if (getDisease() != null) {
			hashcode = hashcode + (int) getDisease().getId();
		}
		if (getSymptom() != null) {
			hashcode = hashcode + (int) getSymptom().getId();
		}
		return hashcode;
	}

	@Column(name = "id", nullable = false)
	@Id
	private int id;

	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity = DiseasePo.class, fetch = FetchType.LAZY)
	@org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.LOCK })
	@JoinColumns({ @JoinColumn(name = "disease_id", referencedColumnName = "id") })
	@org.hibernate.annotations.LazyToOne(value = org.hibernate.annotations.LazyToOneOption.NO_PROXY)
	private DiseasePo disease;

	@PrimaryKeyJoinColumn
	@ManyToOne(targetEntity = SymptomPo.class, fetch = FetchType.LAZY)
	@org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.LOCK })
	@JoinColumns({ @JoinColumn(name = "symptom_id", referencedColumnName = "id") })
	@org.hibernate.annotations.LazyToOne(value = org.hibernate.annotations.LazyToOneOption.NO_PROXY)
	private SymptomPo symptom;

	public void setId(int value) {
		this.id = value;
	}

	public int getId() {
		return id;
	}

	public void setDisease(DiseasePo disease) {
		this.disease = disease;
	}

	public DiseasePo getDisease() {
		return disease;
	}

	public void setSymptom(SymptomPo symptom) {
		this.symptom = symptom;
	}

	public SymptomPo getSymptom() {
		return symptom;
	}

	public String toString() {
		return String.valueOf(getId() + " " + ((getDisease() == null) ? "" : String.valueOf(getDisease().getId())) + " "
				+ ((getSymptom() == null) ? "" : String.valueOf(getSymptom().getId())));
	}
}
